unit uAddWindowOption;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtDlgs, StdCtrls, ExtCtrls, Mask, DBCtrlsEh, DBLookupEh;

type
  TfAddWindowOption = class(TForm)
    Label2: TLabel;
    DBLookupComboboxEh1: TDBLookupComboboxEh;
    GroupBox1: TGroupBox;
    Image1: TImage;
    Button1: TButton;
    Button2: TButton;
    OpenPictureDialog1: TOpenPictureDialog;
    procedure Image1DblClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fAddWindowOption: TfAddWindowOption;

implementation

uses uDBData, uDBCommand;

{$R *.dfm}

procedure TfAddWindowOption.Image1DblClick(Sender: TObject);
begin
  if(OpenPictureDialog1.Execute())then
  begin
    if(OpenPictureDialog1.FileName <> '')then
    begin
      Image1.Picture.Bitmap.LoadFromFile(OpenPictureDialog1.FileName);
      Button1.Enabled := True;
    end
    else Button1.Enabled := False;
  end;
end;

procedure TfAddWindowOption.Button2Click(Sender: TObject);
begin
  Close();
end;

procedure TfAddWindowOption.Button1Click(Sender: TObject);
begin
  if(OpenPictureDialog1.FileName <> '')then
  begin
    fDBData.dWindowOption.DataSet.Close();
    fDBCommand.qAddWindowOption.ParamByName('IDMaterial').Value := fDBData.dMaterial.DataSet.FieldByName('MaterialId').AsInteger;
    fDBCommand.qAddWindowOption.ParamByName('OptionImage').Assign(Image1.Picture.Bitmap);
    fDBCommand.qAddWindowOption.Execute();
    fDBData.dWindowOption.DataSet.Open();
  end;
  Image1.Picture.Bitmap.FreeImage();
  Button1.Enabled := False;
  Close();
end;

end.
